<?php
class DomainAction {
	public function index() {
		global $sMethod;
		$sMethod = 'index';
		if (! $_GET ['m']) {
			$_GET ['m'] = 'add';
		}
		$sUrl = './?' . Base::getSearch ( array ('m', 'id' ) );
		$aList = Base::$oBase->Domain_getList_model ();
		Base::$oBase->Template_assign ( 'url', $sUrl );
		Base::$oBase->Template_assign ( 'list', $aList );
	}
	
	public function add() {
		if ($_POST) {
			Base::$oBase->Domain_add_model ( $_POST );
			Base::location ( './?' . Base::getSearch ( array ('m' ) ) );
		}
		$this->index ();
	}
	
	public function edit() {
		if ($_POST) {
			$_POST ['id'] = $_GET ['id'];
			Base::$oBase->Domain_edit_model ( $_POST );
			Base::location ( './?' . Base::getSearch ( array ('m', 'id' ) ) );
		}
		$aInfo = Base::$oBase->Domain_get_model ( $_GET ['id'] );
		Base::$oBase->Template_assign ( 'info', $aInfo );
		$this->index ();
	}
	
	public function del() {
		if ($_POST ['confirm']) {
			Base::$oBase->Domain_del_model ( $_GET ['id'] );
			Base::location ( './?' . Base::getSearch ( array ('m', 'id' ) ) );
		} elseif ($_POST ['cancel']) {
			Base::location ( './?' . Base::getSearch ( array ('m', 'id' ) ) );
		}
		$this->index ();
	}
}